package com.admin.model.dto;

import com.admin.model.base.BaseDto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;
import java.util.List;

/**
 * (Menu)实体类
 *
 * @author makejava
 * @since 2021-01-31 20:10:18
 */

@ApiModel("菜单实体类")
@Data
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
public class MenuDto extends BaseDto implements Serializable {
    private static final long serialVersionUID = 237720222101236808L;
    /**
     * id
     */
    @NotNull(message = "id不能为空", groups = Update.class)
    @Null(message = "id必须为空", groups = Create.class)
    @ApiModelProperty("id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;
    /**
     * 上级菜单ID
     */
    @NotNull(message = "上级菜单为空", groups = Create.class)
    @ApiModelProperty("上级菜单ID")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long pid;
    /**
     * 菜单类型
     */
    @NotNull(message = "菜单类型不能为空", groups = Create.class)
    @ApiModelProperty("菜单类型")
    private Integer type;
    /**
     * 菜单标题
     */
    @NotBlank(message = "菜单标题不能为空", groups = Create.class)
    @ApiModelProperty("菜单标题")
    private String title;
    /**
     * 组件名称
     */
    @ApiModelProperty("组件名称")
    private String name;
    /**
     * 组件地址
     */
    @ApiModelProperty("组件地址")
    private String component;
    /**
     * 排序
     */
    @NotNull(message = "排序不能为空", groups = Create.class)
    @ApiModelProperty("排序")
    private Integer sort;
    /**
     * 图标
     */
    @ApiModelProperty("图标")
    private String icon;
    /**
     * 链接地址
     */
    @ApiModelProperty("链接地址")
    private String path;
    /**
     * 是否外链
     */
    @ApiModelProperty("是否外链")
    private Boolean frame;
    /**
     * 缓存
     */
    @ApiModelProperty("缓存")
    private Boolean cache;
    /**
     * 隐藏
     */
    @ApiModelProperty("隐藏")
    private Boolean hidden;
    /**
     * 权限
     */
    @ApiModelProperty("权限")
    private String permission;
    /**
     * 子菜单
     */
    @ApiModelProperty("子菜单")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private List<MenuDto> children;
}